<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtdivwindow.inc.php");
use_unit("components4phpfull/jtgroupbox.inc.php");
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class routeList2 extends Page
{
       public $Label3 = null;
       public $Image4 = null;
       public $Image3 = null;
       public $JTDivInfo = null;
       public $JTGroupBox5 = null;
       public $Image2 = null;
       public $Label13 = null;
       public $imgInfo = null;
       public $imgBack = null;
       public $lblplate = null;
       public $lblyear = null;
       public $lblmodel = null;
       public $lblmake = null;
       public $Label2 = null;
       public $Label1 = null;
       public $JTJavaScript1 = null;
       public $Image1 = null;
       public $lblEmpName = null;
       public $lblEmpId = null;
       public $imageAddroute = null;
       public $hiddenEmp = null;
       public $JTRouteList = null;
       public $JTSiteTheme1 = null;
       function imgInfoJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivInfo').Show();
       <?php

       }

       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back.png"
       <?php

       }

       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back2.png"
       <?php

       }

       function routeList2JSLoad($sender, $params)
       {

       ?>
       document.getElementById('JTRouteList_colitem_hdr_0').width = '138';
       document.getElementById('JTRouteList_colitem_hdr_1').width = '138';
       document.getElementById('JTRouteList_colitem_hdr_2').width = '138';
       document.getElementById('JTRouteList_colitem_hdr_3').width = '138';
       document.getElementById('JTRouteList_colitem_hdr_4').width = '138';
       document.getElementById('JTRouteList_colitem_hdr_5').width = '138';
       document.getElementById('JTRouteList_colitem_hdr_6').width = '200';

       document.getElementById('JTRouteList_colitem_body_0').width = '138';
       document.getElementById('JTRouteList_colitem_body_1').width = '138';
       document.getElementById('JTRouteList_colitem_body_2').width = '138';
       document.getElementById('JTRouteList_colitem_body_3').width = '138';
       document.getElementById('JTRouteList_colitem_body_4').width = '138';
       document.getElementById('JTRouteList_colitem_body_5').width = '138';
       document.getElementById('JTRouteList_colitem_body_6').width = '200';

       <?php

       }

       function genRandomString()
       {
       $length = 10;
       $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
       $string ='';

       for ($p = 0; $p < $length; $p++)
       {
        $string .= $characters[mt_rand(0, strlen($characters))];
       }

       return $string;
       }

       function imageAddrouteClick($sender, $params)
       {
        $_SESSION['temp_job_id'] = $this->genRandomString();
        redirect('route_job_create2.php?emp='.$this->hiddenEmp->getValue());
       }

       function imageAddrouteJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imageAddroute'].src="image/add_new.png"
       <?php

       }

       function imageAddrouteJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imageAddroute'].src="image/add_new_blue.png"
       <?php

       }

       function routeList2Create($sender, $params)
       {
       if($_SESSION['isAdmin']!=1)
       {
       $this->imageAddroute->setVisible(false);
       }



       $emp = $_GET['emp'];
       $this->hiddenEmp->setValue($emp);

       if($_SESSION['access_route']==1)
       {
       $this->imageAddroute->Visible=false;
       }

       if($_SESSION['access_route']==2)
       {
       $this->imageAddroute->Visible=true;
       }

       $query_emp = "select * from vehicle_tbl where vehicle_id='".$this->hiddenEmp->getValue()."'";
       $result_emp = mysql_query($query_emp)or die(mysql_error());
       $row_emp = mysql_fetch_array($result_emp);

       $this->lblplate->Caption=$row_emp['veh_num'];
       $this->lblyear->Caption=$row_emp['year'];
       $this->lblmake->Caption=$row_emp['manufacturer_name'];
       $this->lblmodel->Caption=$row_emp['model_name'];

       //$this->imageAddroute->setLink('route_job_create.php?emp='.$this->hiddenEmp->getValue());

       }

       function JTRouteListShow($sender, $params)
       {
       $query1 = "select * from route_tbl where emp_id='".$this->hiddenEmp->getValue()."' order by start_date desc";
       $result = mysql_query($query1)or die(mysql_error());

        $arr = array();
        while($row = mysql_fetch_array($result))
          {
            //$emp_id = $row['autoid'];
            $route = $row['route_id'];
            $veh_id = $row['veh_id'];

            $query_veh = "select * from vehicle_tbl where vehicle_id='".$veh_id."'";
            $result_veh = mysql_query($query_veh)or die(mysql_error());
            $row_veh = mysql_fetch_array($result_veh);

            $route_date = "<a href=route_job_edit2.php?emp=".$this->hiddenEmp->getValue()."&route=".$route." title='edit route list'>".$row['start_date']."</a>";

            //<a href=route_in.php?emp=".$this->hiddenEmp->getValue()."&job_id=".$route."><img src='image/route.png' title='vehicle route' no border></a>

            if($_SESSION['access_route']==1)
            {
            $tools = "<a href=route_expense_list2.php?emp=".$this->hiddenEmp->getValue()."&route=".$route."><img src='image/rexpense.png' title='account' no border></a>
            <a href=route_fuel_list2.php?emp=".$this->hiddenEmp->getValue()."&route=".$route."&veh=".$veh_id."><img src='image/rfuel.png' title='fuel' no border></a>
            <img onclick=window.open('print_locs3.php?job_id=".$row['route_id']."','popup','width=850,height=768,scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); src='image/dispatch_form.png' title='Print dispatch form' style='cursor:pointer'>
            <img onclick=window.open('print_locs4.php?job_id=".$row['route_id']."','popup','width=850,height=768,scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); src='image/print.png' title='Print' style='cursor:pointer'>";
            //<img onclick=window.open('print_locs.php?job_id=".$row['route_id']."','popup','width=850,height=768,scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); src='image/print.png' title='Print dispatch form' style='cursor:pointer'>
            //<img onclick=js_deleteRoute('".$this->hiddenEmp->getValue()."','".$route."'); src='image/delete.png' title='delete' style='cursor:pointer' no border>";
            //<a href=route_log_delete.php?emp=".$this->hiddenEmp->getValue()."&route=".$route."><img src='image/delete_orange.jpg' title='delete' no border></a>";
            }

            //<a href=route_job_list.php?emp=".$this->hiddenEmp->getValue()."&route=".$route."><img src='image/route.png' title='vehicle route' no border></a>

            if($_SESSION['access_route']==2)
            {
            $tools = "<a href=route_expense_list2.php?emp=".$this->hiddenEmp->getValue()."&route=".$route."><img src='image/rexpense.png' title='account' no border></a>
            <a href=route_fuel_list2.php?emp=".$this->hiddenEmp->getValue()."&route=".$route."&veh=".$veh_id."><img src='image/rfuel.png' title='fuel' no border></a>
            <img onclick=window.open('print_locs3.php?job_id=".$row['route_id']."','popup','width=850,height=768,scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); src='image/dispatch_form.png' title='Print dispatch form' style='cursor:pointer'>
            <img onclick=window.open('print_locs4.php?job_id=".$row['route_id']."','popup','width=850,height=768,scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); src='image/print.png' title='Print' style='cursor:pointer'>
            <img onclick=js_deleteRoute('".$this->hiddenEmp->getValue()."','".$route."'); src='image/delete.png' title='delete' style='cursor:pointer' no border>";
            //<img onclick=window.open('print_locs.php?job_id=".$row['route_id']."','popup','width=850,height=768,scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); src='image/print.png' title='Print dispatch form' style='cursor:pointer'>
            //<img onclick=js_deleteRoute('".$this->hiddenEmp->getValue()."','".$route."'); src='image/delete.png' title='delete' style='cursor:pointer' no border>";
            //<a href=route_log_delete.php?emp=".$this->hiddenEmp->getValue()."&route=".$route."><img src='image/delete_orange.jpg' title='delete' no border></a>";
            }




            $arr[] = array(
                        'Dispatch Date' => $route_date,
                        'Dispatch ID' => $row['job_no'],
                        'End Date' => $row['end_date'],
                        'Description' => $row['description'],
                        //'Plate No.' => $row_veh['veh_num'],
                        //'Year' => $row_veh['year'],
                        //'Make' => $row_veh['manufacturer_name'],
                        //'Model' => $row_veh['model_name'],
                        //'Total Hrs on Job' => $row['hrs'],
                        //'Mileage' => $row['miles'],
                        //'Description ' => $row['description'],
                        'Tools' => $tools
                        );


          }

            $this->JTRouteList->setCellData($arr);


       }

}

global $application;

global $routeList2;

//Creates the form
$routeList2=new routeList2($application);

//Read from resource file
$routeList2->loadResource(__FILE__);

//Shows the form
$routeList2->show();

?>